//
// Created by Administrator on 2024/2/15.
// 链表练习
//

#include <iostream>
#include <vector>
using namespace std;

struct Node{
    int a;
    Node *p;
};

int main()
{
    vector<int> l={1,2,3,4,5,6,7};
    Node head={l[0],NULL};
    Node *cur = &head;
    for (int i = 1; i < l.size(); ++i)
    {
        // 这里要用new Node() 不能用 Node t
        // 因为每次地址不一样才能形成链表
        Node *t =new Node();
        t->a=l[i];
        cur->p=t;
        cur=cur->p;
    }

    // printf
    cur = &head;
    while(cur!=NULL)
    {
        cout<<cur->a<<endl;
        cur=cur->p;
    }
    return 0;
}